package com.example.hospital.api.controller;

import cn.hutool.core.bean.BeanUtil;
import com.example.hospital.api.annotations.ResponseResult;
import com.example.hospital.api.common.Result;
import com.example.hospital.api.common.vo.LoginVo;
import com.example.hospital.api.controller.form.LoginForm;
import com.example.hospital.api.service.MisUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

@RestController
@RequestMapping("/mis_user")
@ResponseResult
public class MisUserController {
    @Resource
    MisUserService misUserService;

    @PostMapping("/login")
    public LoginVo login(@RequestBody @Valid LoginForm form) throws Exception {
        Map map = BeanUtil.beanToMap(form);
        return misUserService.login(map);
    }
}
